package com.sgb.kjwl.di.transport;

import androidx.lifecycle.ViewModelProvider;

import com.sgb.kjwl.repository.TransportRepertory;
import com.sgb.kjwl.repository.impl.TransportRepertoryImpl;
import com.sgb.kjwl.view.ui.fragment.transport.CarsFragment;
import com.sgb.kjwl.view.ui.fragment.transport.GoodsFragment;
import com.sgb.kjwl.view.ui.fragment.transport.GoodsHallListFragment;
import com.sgb.kjwl.view.ui.fragment.transport.GoodsListFragment;
import com.sgb.kjwl.view.ui.fragment.transport.MapCarrierFragment;
import com.sgb.kjwl.view.ui.fragment.transport.MapCarsFragment;
import com.sgb.kjwl.view.ui.fragment.transport.MapGoodsFragment;
import com.sgb.kjwl.view.ui.fragment.transport.SearchTransportGoodsFragment;
import com.sgb.kjwl.view.ui.fragment.transport.TransportOrderOwnerFragment;
import com.sgb.kjwl.viewmodel.transport.CarsModel;
import com.sgb.kjwl.viewmodel.transport.GoodsInfofrgModel3;
import com.sgb.kjwl.viewmodel.transport.GoodsListAndMapModel;
import com.sgb.kjwl.viewmodel.transport.GoodsModel;
import com.sgb.kjwl.viewmodel.transport.MapCarrierFramgentModel;
import com.sgb.kjwl.viewmodel.transport.MapCarsFramgentModel;
import com.sgb.kjwl.viewmodel.transport.MapGoodsFramgentModel;
import com.sgb.kjwl.viewmodel.transport.SearchGoodsModel;
import com.sgb.kjwl.viewmodel.transport.TransportOrderOwnerViewModel;
import com.swgk.core.base.di.Fragment;
import com.swgk.core.base.api.BaseApiSource;
import com.swgk.core.base.model.preference.BasePreferenceSource;

import dagger.Module;
import dagger.Provides;

@Module
public class TransportFragModule {
    private MapGoodsFragment mapGoodsFragment;
    private MapCarsFragment mapCarsFragment;
    private GoodsListFragment goodsListFragment;
    private GoodsHallListFragment goodsHallListFragment;
    private GoodsFragment goodsFragment;
    private CarsFragment carsFragment;
    private SearchTransportGoodsFragment searchTransportGoodsFragment;
    private TransportOrderOwnerFragment transportOrderOwnerFragment;
    private MapCarrierFragment mapCarrierFragment;

    public TransportFragModule(MapCarrierFragment mapCarrierFragment) {
        this.mapCarrierFragment = mapCarrierFragment;
    }
    public TransportFragModule(GoodsHallListFragment goodsHallListFragment) {
        this.goodsHallListFragment = goodsHallListFragment;
    }

    public TransportFragModule(SearchTransportGoodsFragment searchTransportGoodsFragment) {
        this.searchTransportGoodsFragment = searchTransportGoodsFragment;
    }

    public TransportFragModule(GoodsListFragment goodsListFragment) {
        this.goodsListFragment = goodsListFragment;
    }

    public TransportFragModule(GoodsFragment goodsFragment) {
        this.goodsFragment = goodsFragment;
    }

    public TransportFragModule(MapGoodsFragment mapGoodsFragments) {
        this.mapGoodsFragment = mapGoodsFragments;
    }

    public TransportFragModule(MapCarsFragment mapCarsFragments) {
        this.mapCarsFragment = mapCarsFragments;
    }

    public TransportFragModule(CarsFragment carsFragment) {
        this.carsFragment = carsFragment;
    }

    public TransportFragModule(TransportOrderOwnerFragment transportOrderOwnerFragment) {
        this.transportOrderOwnerFragment = transportOrderOwnerFragment;
    }

    @Provides
    @Fragment
    TransportRepertory provideMachineRepertory(BaseApiSource apiSource, BasePreferenceSource preferenceSource) {
        return new TransportRepertoryImpl(apiSource, preferenceSource);
    }

    @Provides
    @Fragment
    GoodsInfofrgModel3 provideGoodsInfofrgModel3(TransportRepertory repertory) {
        return new GoodsInfofrgModel3(goodsListFragment, repertory);
    }

    @Provides
    @Fragment
    GoodsListAndMapModel provideGoodsListAndMapModel(TransportRepertory repertory) {
        return new GoodsListAndMapModel(goodsHallListFragment, repertory);
    }


    @Provides
    @Fragment
    GoodsModel provideGoodsModel(TransportRepertory repertory) {
        return new GoodsModel(goodsFragment, repertory);
    }

    @Provides
    @Fragment
    CarsModel provideCarsModel(TransportRepertory repertory) {
        return new ViewModelProvider(carsFragment).get(CarsModel.class);
    }

    @Provides
    @Fragment
    MapGoodsFramgentModel provideMapGoodsFragmentModel(TransportRepertory repertory) {
        return new MapGoodsFramgentModel(mapGoodsFragment, repertory);
    }

    @Provides
    @Fragment
    MapCarsFramgentModel provideMapCarsFragmentModel(TransportRepertory repertory) {
        return new ViewModelProvider(mapCarsFragment).get(MapCarsFramgentModel.class);
    }
    @Provides
    @Fragment
    MapCarrierFramgentModel provideMapCarrierFramgentModel(){
        return new ViewModelProvider(mapCarrierFragment).get(MapCarrierFramgentModel.class);

    }

    @Provides
    @Fragment
    SearchGoodsModel provideSearchGoodsModel(){
        return  new ViewModelProvider(searchTransportGoodsFragment).get(SearchGoodsModel.class);
    }

    @Provides
    @Fragment
    TransportOrderOwnerViewModel provideTransportOrderOwnerViewModel(TransportRepertory repertory) {
        return new TransportOrderOwnerViewModel(transportOrderOwnerFragment);
    }

}

